import { createApp ,watch} from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'
// 导入重置css
import 'normalize.css'
// 导入el 的组件与样式
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
 

const app = createApp(App)
const pinia = createPinia()
app.use(pinia)
app.use(router)
app.use(ElementPlus)

app.mount('#app')

// 实现对整个pinia的本地存储
watch(pinia.state,(state)=>{
  // 监听pinia state的而变化 实现了对整个pinia的存
  sessionStorage.setItem('piniaState',JSON.stringify(state))
},{deep:true})

// 运行main.js 把pinia数据取回来
pinia.state.value = JSON.parse(sessionStorage.getItem('piniaState')||'{}')

